#######################################################################
#
#  This makefile creates a library for distributed SuperLU.
#  The files are organized as follows:
#
#       ALLAUX  -- Auxiliary routines called from all precisions
#       DSLUSRC -- Double precision real serial SuperLU routines
#       DPLUSRC -- Double precision real parallel SuperLU routines
#       ZSLUSRC -- Double precision complex serial SuperLU routines
#       ZPLUSRC -- Double precision complex parallel SuperLU routines
#
#  The library can be set up to include routines for any combination
#  of the two precisions.  To create or add to the library, enter make
#  followed by one or more of the precisions desired.  Some examples:
#       make double
#       make double complex16
#  Alternatively, the command
#       make
#  without any arguments creates a library of all two precisions.
#  The library is called
#       superlu.a
#  and is created at the next higher directory level.
#
#  To remove the object files after the library is created, enter
#       make clean
#
#######################################################################
#include ../make.inc

include ../../../Makefile.def
DSUPERLULIB = $(DISTRIBUTED_SUPERLU_LIBRARY)
#DSUPERLULIB = a.lib
ARCH = $(AR)
ARCHFLAGS = $(ARFLAGS)

#
# Precision independent routines
#
ALLAUX 	= sp_ienv.o etree.o sp_colorder.o get_perm_c.o \
	  mmd.o comm.o memory.o util.o superlu_grid.o \
	  pxerbla.o superlu_timer.o GetDiagU.o mc64ad.o symbfact.o \
	  psymbfact.o psymbfact_util.o get_perm_c_parmetis.o

#### LAPACK auxiliary routines
LAAUX	= lsame.o xerbla.o slamch.o dlamch.o

#
# Routines literally taken from SuperLU
#
DSLUSRC	= dlangs.o dgsequ.o dlaqgs.o dutil.o \
	  dmemory.o dmyblas2.o dsp_blas2.o dsp_blas3.o
ZSLUSRC	= dcomplex.o zlangs.o zgsequ.o zlaqgs.o zutil.o \
	  zmemory.o zmyblas2.o dmemory.o zsp_blas2.o zsp_blas3.o

#
# Routines for double precision parallel SuperLU
# DPLUSRC = dldperm.o ddistribute.o pdgstrf.o pdgstrs_Bglobal.o 
DPLUSRC = dldperm.o ddistribute.o pdgstrf.o pdgstrs_Bglobal.o \
	  pdgstrs1.o pdgssvx_ABglobal.o pdgsrfs_ABXglobal.o pdgsmv_AXglobal.o\
	  pdgssvx.o pdgstrs.o pddistribute.o pdlangs.o pdutil.o \
	  pdgsequ.o pdlaqgs.o pdgsrfs.o pdgsmv.o pdgstrs_lsum.o \
	  pdsymbfact_distdata.o

#
# Routines for double complex parallel SuperLU
# ZPLUSRC = zldperm.o zdistribute.o pzgssvx_ABglobal.o pzgstrf_irecv.o
ZPLUSRC = zldperm.o zdistribute.o pzgssvx_ABglobal.o pzgstrf.o \
	  pzgstrs1.o pzgstrs_Bglobal.o pzgsrfs_ABXglobal.o pzgsmv_AXglobal.o \
	  pzgssvx.o pzgstrs.o pzdistribute.o pzlangs.o pzutil.o \
	  pzgsequ.o pzlaqgs.o pzgsrfs.o pzgsmv.o pzgstrs_lsum.o \
	  pzsymbfact_distdata.o

all:  double

double: $(DSLUSRC) $(DPLUSRC) $(ALLAUX) $(LAAUX)
	$(ARCH) $(ARCHFLAGS) $(DSUPERLULIB) \
		$(DSLUSRC) $(DPLUSRC) $(ALLAUX) $(LAAUX)
	$(RANLIB) $(DSUPERLULIB)

complex16: $(ZSLUSRC) $(ZPLUSRC) $(ALLAUX) $(LAAUX)
	$(ARCH) $(ARCHFLAGS) $(DSUPERLULIB) \
		$(ZSLUSRC) $(ZPLUSRC) $(ALLAUX) $(LAAUX)
	$(RANLIB) $(DSUPERLULIB)


##################################
# Do not optimize these routines #
##################################
slamch.o: slamch.c ; $(CC) $(NOOPTS) $(CDEFS) -c $<
dlamch.o: dlamch.c ; $(CC) $(NOOPTS) $(CDEFS) -c $<
##################################

.c.o:
	$(CC) $(CFLAGS) $(CDEFS) $(BLASDEF) -c $< $(VERBOSE)

.f.o:
	$(FORTRAN) $(FFLAGS) -c $< $(VERBOSE)

clean:	
	rm -f *.o $(DSUPERLULIB)


